
BIN = main
RM = rm -vf
PLIB = geo jeu # aff
LIBCMAS = lablgl.cma lablglut.cma unix.cma
PCMAS = $(foreach lib, $(PLIB), $(addprefix $(lib), .cmo))
COMPIL = ocamlc
FLAGS = -I +lablgl

all: $(BIN) 

%: $(PCMAS) %.ml
	$(COMPIL) $(FLAGS) -o $@ $(LIBCMAS) $+

%.cma: %.cmo
	$(COMPIL) -a %< -o $@

%.cmo: %.ml %.cmi
	$(COMPIL) -c $<
	
%.cmi: %.mli
	$(COMPIL) -c $<

#aff.cmi: aff.mli geo.cmi


#aff.cma: geo.cma aff.cmo
#	$(COMPIL) $(FLAGS) -o $@ -a $(LIBCMAS) $+

#aff.cmo: aff.ml aff.cmi
#	$(COMPIL) $(FLAGS) -c $<

#jeu.mli: jeu.ml geo.cmo aff.cmo
#	$(RM) $@
#	$(COMPIL) -i jeu.ml > $@

jeu.mli: jeu.ml geo.cmo
	$(RM) $@
	$(COMPIL) $(FLAGS) -i jeu.ml > $@

jeu.cmi: jeu.mli geo.cmi
	$(COMPIL) $(FLAGS) -c $<

jeu.cma: geo.cma jeu.cmo
	$(COMPIL) $(FLAGS) -o $@ -a $(LIBCMAS) $+

jeu.cmo: jeu.ml jeu.cmi
	$(COMPIL) $(FLAGS) -c $<


mrproper : clean
	 $(RM) $(BIN)

clean:
	$(RM) *.o *.cmx *.cmi *.cma *.cmo
	
.PHONY: all clean mrproper
